package com.vv.tools.common.message;

import java.text.MessageFormat;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author liwen
 */
@Getter
@AllArgsConstructor
public enum ResultEnum {

    SUCCESS("0", "success"),
    EXCEPTION("500", "服务异常"),
    VALID_EXCEPTION("999", "参数异常, {0}"),
    HTTP_CLIENT_EXCEPTION("400", "http exception, {0}"),

    // auth: 10 - 00 - xx
    AUTH_ACCOUNT_EXPIRED("100001", "账号过期"),
    AUTH_BAD_CREDENTIALS("100002", "用户名或密码错误"),
    AUTH_CREDENTIALS_EXPIRED("100003", "密码过期"),
    AUTH_DISABLED("100004", "账户被禁用"),
    AUTH_LOCKED("100005", "账户被锁"),
    AUTH_INTERNAL_AUTHENTICATION_SERVICE("100006", "服务异常"),
    AUTH_USERNAME_NOT_FOUND("100007", "用户不存在"),
    AUTH_LOGIN_ACCESS_DEFINE("100008", "无访问权限"),
    AUTH_LOGIN_AUTHENTICATION("100009", "用户未登录"),
    AUTH_CAPTCHA_NOT_RIGHT("100010", "验证码不正确"),

    // users: 20 - 00 -xx
    USERS_USER_NOT_EXIST("200001", "用户不存在"),
    USERS_USERNAME_REPEAT("200002", "用户名已存在"),
    USERS_CUR_USER_NOT_DELETE("200004", "当前用户不能删除"),
    SUPER_ADMIN_NOT_DELETE("200003", "管理员用户不能删除"),

    // role: 30 -00 -xx
    ROLES_ROLE_NOT_EXIST("200001", "角色不存在"),
    ROLES_NAME_REPEAT("200002", "角色名已存在"),
    ROLES_CUR_USER_NOT_DELETE("200004", "当前角色不能删除"),
    SUPER_ADMIN_ROLE_NOT_DELETE("200003", "管理员角色不能删除");

    private final String code;

    private final String message;

    public String format(Object... args) {
        return MessageFormat.format(this.getMessage(), args);
    }

}
